/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmQuanLyKhuyenMai.java
 *
 * Created on Aug 22, 2012, 3:09:01 PM
 */
package gui;

import dao.CuaHangDAO;
import dao.DanhMucDAO;
import dao.KhoSanPhamDAO;
import dao.KhuyenMaiDAO;
import dao.SanPhamDAO;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
import java.util.Vector;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import pojo.Cuahang;
import pojo.Danhmuc;
import pojo.Khosanpham;
import pojo.Khuyenmai;
import pojo.Sanpham;

/**
 *
 * @author dtth
 */
public class frmQuanLyKhuyenMai extends javax.swing.JFrame {

    /**
     * Creates new form frmQuanLyKhuyenMai
     */
    private Cuahang _cuahang;
    private List<Khuyenmai> _lkhuyenmai;
    private List<Danhmuc> _ldanhmuc;
    private List<Sanpham> _lsanpham;
    private List<Khosanpham> _lkhosanpham;
    private int _rowTable;

    public frmQuanLyKhuyenMai() {
        initComponents();

        //  List<Cuahang> lcuahang = CuaHangDAO.layDanhSachCuaHang();
        this._cuahang = new Cuahang();//chi de test chuong trinh
        this._cuahang.setMacuahang(1);

        this._lkhuyenmai = null;
        this._ldanhmuc = null;
        this._lsanpham = null;
        this._lkhosanpham = null;
        this._rowTable = 0;

        fillJCbxKhuyenMai();
        float tile = Float.valueOf(this._lkhuyenmai.get(0).getTylegiamgia().toString());
        this.jtfTyLe.setText(String.valueOf(tile));
        this.jlblTuNgay.setText(this._lkhuyenmai.get(0).getNgaybdkm().toString());
        this.jlblDenNgay.setText(this._lkhuyenmai.get(0).getNgayktkm().toString());

        this._ldanhmuc = DanhMucDAO.layDanhSachSanPham_DanhMuc(this._cuahang);
        fillJCbxDanhMuc();
        if (this._ldanhmuc.size() > 0) {
            fillJCbxSanPham(this._ldanhmuc.get(0));
            fillJTable(this._ldanhmuc.get(0));
        }

        //#########################
        this.jLabel2.setVisible(false);
        this.jcbxSanPham.setVisible(false);

    }

    public frmQuanLyKhuyenMai(Cuahang cuahang) {
        initComponents();

        this._cuahang = cuahang;

        this._lkhuyenmai = null;
        this._ldanhmuc = null;
        this._lsanpham = null;
        this._lkhosanpham = null;
        this._rowTable = 0;

        fillJCbxKhuyenMai();
        float tile = Float.valueOf(this._lkhuyenmai.get(0).getTylegiamgia().toString());
        this.jtfTyLe.setText(String.valueOf(tile));
        this.jlblTuNgay.setText(this._lkhuyenmai.get(0).getNgaybdkm().toString());
        this.jlblDenNgay.setText(this._lkhuyenmai.get(0).getNgayktkm().toString());

        this._ldanhmuc = DanhMucDAO.layDanhSachSanPham_DanhMuc(this._cuahang);
        fillJCbxDanhMuc();
        if (this._ldanhmuc.size() > 0) {
            fillJCbxSanPham(this._ldanhmuc.get(0));
            fillJTable(this._ldanhmuc.get(0));
        }

        //#########################
        this.jLabel2.setVisible(false);
        this.jcbxSanPham.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtbSanPham = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jcbxSanPham = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        jcbxDanhMuc = new javax.swing.JComboBox();
        jcbxKhuyenMai = new javax.swing.JComboBox();
        jbtnTaoKhuyenMai = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jtfTyLe = new javax.swing.JTextField();
        jlblTuNgay = new javax.swing.JLabel();
        jlblDenNgay = new javax.swing.JLabel();
        jbtnThaoBo = new javax.swing.JButton();
        jbtnDong = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(700, 510));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("QUẢN LÝ KHUYẾN MÃI");

        jtbSanPham.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jtbSanPham.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtbSanPhamMouseClicked(evt);
            }
        });
        jtbSanPham.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtbSanPhamKeyPressed(evt);
            }
        });
        jScrollPane1.setViewportView(jtbSanPham);

        jLabel2.setText("Sản Phẩm");

        jLabel3.setText("Khuyễn Mãi");

        jLabel8.setText("Danh Mục");

        jcbxDanhMuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbxDanhMucActionPerformed(evt);
            }
        });

        jcbxKhuyenMai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbxKhuyenMaiActionPerformed(evt);
            }
        });

        jbtnTaoKhuyenMai.setText("Tạo Khuyến Mãi Mới");
        jbtnTaoKhuyenMai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnTaoKhuyenMaiActionPerformed(evt);
            }
        });

        jLabel4.setText("Tỷ Lệ Khuyến Mãi");

        jLabel5.setText("Từ Ngày: ");

        jLabel6.setText("Đến Ngày: ");

        jButton1.setText("Cập Nhật");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jtfTyLe.setEditable(false);

        jlblTuNgay.setFont(new java.awt.Font("Tahoma", 1, 11));
        jlblTuNgay.setText("jLabel7");

        jlblDenNgay.setFont(new java.awt.Font("Tahoma", 1, 11));
        jlblDenNgay.setText("jLabel9");

        jbtnThaoBo.setText("Tháo Bỏ Khuyến Mãi");
        jbtnThaoBo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnThaoBoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jcbxDanhMuc, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jcbxSanPham, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap(263, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3))
                        .addGap(30, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtfTyLe)
                            .addComponent(jcbxKhuyenMai, 0, 174, Short.MAX_VALUE))
                        .addGap(76, 76, 76))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                                .addComponent(jlblTuNgay)
                                .addGap(72, 72, 72)
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jlblDenNgay)
                                .addGap(61, 61, 61))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jbtnThaoBo)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtnTaoKhuyenMai)
                                .addContainerGap())))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jcbxDanhMuc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jcbxKhuyenMai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jcbxSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jtfTyLe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jlblTuNgay)
                    .addComponent(jlblDenNgay))
                .addGap(13, 13, 13)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jbtnThaoBo)
                    .addComponent(jbtnTaoKhuyenMai))
                .addContainerGap())
        );

        jbtnDong.setText("Đóng");
        jbtnDong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnDongActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(611, Short.MAX_VALUE)
                .addComponent(jbtnDong, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 730, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23))
            .addGroup(layout.createSequentialGroup()
                .addGap(304, 304, 304)
                .addComponent(jLabel1)
                .addContainerGap(314, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbtnDong)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jbtnDongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDongActionPerformed
// TODO add your handling code here:
//    System.exit(1);
    this.setVisible(false);
}//GEN-LAST:event_jbtnDongActionPerformed

private void jtbSanPhamKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtbSanPhamKeyPressed
// TODO add your handling code here:
    this._rowTable = this.jtbSanPham.getSelectedRow();
    int key = evt.getKeyCode();
    if (key == 40) {//nhan nut xuong
        this._rowTable++;
    }
    if (key == 38) {//nhan nutlen
        this._rowTable--;
    }
}//GEN-LAST:event_jtbSanPhamKeyPressed

private void jtbSanPhamMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtbSanPhamMouseClicked
// TODO add your handling code here:
    this._rowTable = this.jtbSanPham.getSelectedRow();
    //   this.jcbxSanPham.setSelectedItem("asdfs");
    //this.jcbxSanPham.setSelectedItem(this._lkhosanpham.get(this._rowTable).getSanpham());
}//GEN-LAST:event_jtbSanPhamMouseClicked

private void jcbxDanhMucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbxDanhMucActionPerformed
// TODO add your handling code here:
    DefaultComboBoxModel cbxModel = new DefaultComboBoxModel();
    this.jcbxSanPham.setModel(cbxModel);

    Danhmuc danhmuc = (Danhmuc) this.jcbxDanhMuc.getSelectedItem();
    List<Sanpham> lSanPham = SanPhamDAO.layDanhSachSanPham(danhmuc);
    for (int i = 0; i < lSanPham.size(); i++) {
        this.jcbxSanPham.addItem(lSanPham.get(i));
    }

    fillJTable(danhmuc);
}//GEN-LAST:event_jcbxDanhMucActionPerformed

private void jbtnTaoKhuyenMaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnTaoKhuyenMaiActionPerformed
// TODO add your handling code here:
    frmKhuyenMai frm = new frmKhuyenMai(this);
    frm.setVisible(true);
}//GEN-LAST:event_jbtnTaoKhuyenMaiActionPerformed

private void jcbxKhuyenMaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbxKhuyenMaiActionPerformed
// TODO add your handling code here:
    float tile = Float.valueOf(this._lkhuyenmai.get(this.jcbxKhuyenMai.getSelectedIndex()).getTylegiamgia().toString());
    this.jtfTyLe.setText(String.valueOf(tile));
    this.jlblTuNgay.setText(this._lkhuyenmai.get(this.jcbxKhuyenMai.getSelectedIndex()).getNgaybdkm().toString());
    this.jlblDenNgay.setText(this._lkhuyenmai.get(this.jcbxKhuyenMai.getSelectedIndex()).getNgayktkm().toString());
}//GEN-LAST:event_jcbxKhuyenMaiActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
    int index = this.jtbSanPham.getSelectedRow();
    Khuyenmai khuyenmai = (Khuyenmai) this.jcbxKhuyenMai.getSelectedItem();
    this._lkhosanpham.get(index).setKhuyenmai(khuyenmai);

    boolean kq = KhoSanPhamDAO.capnhatThongTinKhoSanPham(this._lkhosanpham.get(index));
    if (kq) {
        JOptionPane.showMessageDialog(this, "Cập nhật thành công !", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
    } else {
        JOptionPane.showMessageDialog(this, "Cập nhật không được !", "Thông báo", JOptionPane.WARNING_MESSAGE);
    }

    Danhmuc danhmuc = (Danhmuc) this.jcbxDanhMuc.getSelectedItem();
    fillJTable(danhmuc);
}//GEN-LAST:event_jButton1ActionPerformed

private void jbtnThaoBoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnThaoBoActionPerformed
// TODO add your handling code here:
    int index = this.jtbSanPham.getSelectedRow();
    Khuyenmai khuyenmai = null;
    this._lkhosanpham.get(index).setKhuyenmai(khuyenmai);

    boolean kq = KhoSanPhamDAO.capnhatThongTinKhoSanPham(this._lkhosanpham.get(index));
    if (kq) {
        JOptionPane.showMessageDialog(this, "Gỡ bỏ Khuyến mãi thành công !", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
    } else {
        JOptionPane.showMessageDialog(this, "Gỡ Bỏ Khuyễn Mãi không được !", "Thông báo", JOptionPane.WARNING_MESSAGE);
    }

    Danhmuc danhmuc = (Danhmuc) this.jcbxDanhMuc.getSelectedItem();
    fillJTable(danhmuc);
}//GEN-LAST:event_jbtnThaoBoActionPerformed

    private void fillJCbxDanhMuc() {
        //   this._ldanhmuc = DanhMucDAO.layDanhSachSanPham_DanhMuc(this._cuahang);
        for (int i = 0; i < this._ldanhmuc.size(); i++) {
            this.jcbxDanhMuc.addItem(this._ldanhmuc.get(i));
        }
    }

    private void fillJCbxSanPham(Danhmuc danhmuc) {
        this.jcbxSanPham.setModel(new DefaultComboBoxModel());
        this._lsanpham = SanPhamDAO.layDanhSachSanPham(danhmuc);
        for (int i = 0; i < _ldanhmuc.size(); i++) {
            this.jcbxSanPham.addItem(_lsanpham.get(i));
        }
    }

    public void fillJCbxKhuyenMai() {
        this.jcbxKhuyenMai.setModel(new DefaultComboBoxModel());
        this._lkhuyenmai = KhuyenMaiDAO.layDanhSachKhuyenMai();
        for (int i = 0; i < this._lkhuyenmai.size(); i++) {
            this.jcbxKhuyenMai.addItem(this._lkhuyenmai.get(i));
        }
    }

    private void fillJTable(Danhmuc danhmuc) {
        //     this._lkhosanpham = KhoSanPhamDAO.layDanhSachKhoSanPham();
        this._lkhosanpham = KhoSanPhamDAO.layDanhSachKhoSanPham(danhmuc, this._cuahang);
        DefaultTableModel tableModel = new DefaultTableModel();
        tableModel.addColumn("Sản Phẩm");
        tableModel.addColumn("Khuyễn Mãi");
        tableModel.addColumn("Tỷ Lệ Khuyễn Mãi (%)");
        tableModel.addColumn("Ngày Bắt Đầu");
        tableModel.addColumn("Ngày Kết Thúc");
        this.jtbSanPham.setModel(tableModel);

        for (int i = 0; i < this._lkhosanpham.size(); i++) {
            Vector vt = new Vector();
            vt.add(this._lkhosanpham.get(i).getSanpham().getTensanpham());

            Khuyenmai khuyenmai = this._lkhosanpham.get(i).getKhuyenmai();
            if (khuyenmai != null) {
                vt.add(this._lkhosanpham.get(i).getKhuyenmai().getTenkhuyenmai());
                double tile = this._lkhosanpham.get(i).getKhuyenmai().getTylegiamgia() * 10;
                vt.add((int) tile);
                vt.add(this._lkhosanpham.get(i).getKhuyenmai().getNgaybdkm());
                vt.add(this._lkhosanpham.get(i).getKhuyenmai().getNgayktkm());
            }
            tableModel.addRow(vt);
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmQuanLyKhuyenMai.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmQuanLyKhuyenMai.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmQuanLyKhuyenMai.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmQuanLyKhuyenMai.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmQuanLyKhuyenMai().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnDong;
    private javax.swing.JButton jbtnTaoKhuyenMai;
    private javax.swing.JButton jbtnThaoBo;
    private javax.swing.JComboBox jcbxDanhMuc;
    private javax.swing.JComboBox jcbxKhuyenMai;
    private javax.swing.JComboBox jcbxSanPham;
    private javax.swing.JLabel jlblDenNgay;
    private javax.swing.JLabel jlblTuNgay;
    private javax.swing.JTable jtbSanPham;
    private javax.swing.JTextField jtfTyLe;
    // End of variables declaration//GEN-END:variables
}
